package com.example.idachuappone.index.welcomentity;

import org.json.JSONObject;

public class PersonExpands {
    private String icon;
    private String img;
    private boolean isUrl;
    private String title;
    private WelcomeUri uri;
    private String url;

    public void parseJson(JSONObject json) {
        if (json != null) {
            if (json.has("title")) {
                this.title = json.optString("title");
            }
            if (json.has("uri")) {
                try {
                    this.isUrl = false;
                    WelcomeUri welcomeUri = new WelcomeUri();
                    welcomeUri.parseJson(json.getJSONObject("uri"));
                    this.uri = welcomeUri;
                } catch (Exception e) {
                    this.isUrl = true;
                    this.url = json.optString("uri");
                }
            }
            if (json.has("icon")) {
                this.icon = json.optString("icon");
            }
            if (json.has("img")) {
                this.img = json.optString("img");
            }
        }
    }

    public WelcomeUri getUri() {
        return this.uri;
    }

    public void setUri(WelcomeUri uri) {
        this.uri = uri;
    }

    public boolean isUrl() {
        return this.isUrl;
    }

    public void setUrl(boolean isUrl) {
        this.isUrl = isUrl;
    }

    public String getTitle() {
        return this.title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getUrl() {
        return this.url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getIcon() {
        return this.icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getImg() {
        return this.img;
    }

    public void setImg(String img) {
        this.img = img;
    }
}
